﻿@model PagedList<ADZ_HuodongMaster>
@{
    ViewBag.Title = "活动列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    HuodongQueryModel paramModel = new HuodongQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (HuodongQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}

<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("getlist", "huodong")" method="get">
    <div class="form_query">
        <div>
            活动标题：
            <input type="text" name="huodong_title" id="huodong_title" class="abc input-default" placeholder="" value="@paramModel.huodong_title">&nbsp;
        </div>
        <div>
            活动状态：
            <select id="huodong_status" name="huodong_status">
                <option value="-10">全部</option>
                @{
                    dc = new Dictionary<string, string>();
                    dc.Add(((int)HuodongStatus.Default).ToString(), "未开始");
                    dc.Add(((int)HuodongStatus.InProgress).ToString(), "进行中");
                    dc.Add(((int)HuodongStatus.Finished).ToString(), "已结束");
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.huodong_status.ToString());
            </select>&nbsp;

        </div>
        <div>
            活动开始时间：
            <input type="text" name="beg_time" class="calendar calendar-time" id="beg_time" value="@paramModel.beg_time.ToString(1)"> - <input type="text" name="end_time" class="calendar calendar-time" id="end_time" value="@paramModel.end_time.ToString(1)">&nbsp;
        </div>
        <div>
            <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
            <button type="button" class="btn btn-success" id="btnadd" onclick="document.location='@Url.Action("add","huodong")'">新增</button>
        </div>
    </div>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th>编号</th>
            <th style="text-align:center;vertical-align:middle;">活动图片</th>
            <th>活动标题</th>
            <th>活动状态</th>
            <th>开始时间</th>
            <th>结束时间</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
            <tr class="@HtmlPagerHelper.TrClass(index)">
                <td>@m.huodong_id</td>
                <td style="text-align:center;vertical-align:middle;"><img src="@ImageFileBiz.GetImg(m.img_url,"small")" class="height20" /></td>
                <td>@m.huodong_title</td>
                <td>
                    @if (m.huodong_status == (int)HuodongStatus.Default)
                    {
                        <info>未开始</info>
                    }
                    else if (m.huodong_status == (int)HuodongStatus.InProgress)
                    {
                        <info class="green">进行中</info>
                    }
                    else if (m.huodong_status == (int)HuodongStatus.Finished)
                    {
                        <info class="red">已结束</info>
                    }
                </td>
                <td>@m.begin_time.ToString(1)</td>
                <td>@m.end_time.ToString(1)</td>
                <td>
                    <a href="@Url.Action("add", "huodong", new { id = m.huodong_id})">编辑</a>
                    <a href="javascript:void(0);" onclick="toDel(@m.huodong_id)">删除</a>
                </td>
            </tr>
        }
    }
</table>
<div class="inline pull-left total">
    总行数：@ViewData["AllCount"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>


<script>

    reloadHandler = function () {
        window.location.reload();
    }

    function toDel(id) {
        BUI.Message.Show({
            title: '提示',
            msg: '确定要删除此活动吗?',
            icon: 'question',
            buttons: [
                {
                    text: '确定',
                    elCls: 'button button-primary',
                    handler: function () {
                        url = "@Url.Action("ToDel", "huodong")";
                                parameter = { id: id };
                      $.post(url, parameter, function (result) {
                                    ShowActionResult(result, reloadHandler);
                                });
                                this.close();
                            }
                        },
              {
                            text: '取消',
                  elCls: 'button',
                  handler: function () {
                                this.close();
                            }
              }

            ]
        });
    }
</script>